<?php
/**
 * 活动(activity)表管理
 * Created by PhpStorm.
 * User: deng
 * Date: 2016/7/15
 * Time: 15:00
 */
class PinkDiary2 extends AdminBase{

    protected $do;

    function __construct(){
        parent::__construct();
        $this->do = 'diaryManage';
        $this->{$this->op}();
    }

    function indexAction(){
        include_once template("admin_v2/diaryRecomend");
        exit();
    }

    function reviewindexAction(){
        include_once template("admin_v2/diary_review");
        exit();
    }

    function reviewlistAction(){
        $this->req['start'] = isset($this->req['page']) ? (intval($this->req['page'])-1)*50 : 0;
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'reviewList',
        ], $this->req));
    }

    function reviewpassAction(){
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'reviewPass',
        ], $this->req));
    }

    function reviewnotpassAction(){
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'reviewNotPass',
        ], $this->req));
    }

    function listAction(){
        $this->req['start'] = isset($this->req['page']) ? (intval($this->req['page'])-1)*50 : 0;
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'recommendList',
        ], $this->req));
    }

    function msgdetailAction(){
        $this->fetchData([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'detail',
            'id' => $this->req['id']
        ]);
    }

    function addAction(){
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'recommendEdit',
        ], $this->req));
    }

    function deleteAction(){
        $this->fetchData([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'recommendDelete',
            'id' => $this->req['id']
        ]);
    }

    function flushdayAction(){
        $flush_day = $this->req['dates'] ? trim($this->req['dates']) : '';
        if (empty($flush_day))return $this->errorReturn('参数错误');
        $url = "http://tips.ffrj.net/tips/create?ymd=".$flush_day;
//     $url = "http://tips.ffrj.net/tips/create?ymd=20151106";
        $json = getHttpResponsePOST($url);
        $result = parseData($json);

        $res = 0;
        if (!empty($result['info']['url']) && !empty($result['info']['image_url'])) {
            $res = 1;
            $this->resultReturn();
        }
        $this->errorReturn('操作失败');
    }

    //话题分类
    function topicsCategoryAction(){
        include_once template("admin_v2/diaryTopicsCategory");
        exit();
    }

    function topicsCategoryListAction(){
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'topicsCategoryList',
        ], $this->req));
    }

    function cateTopicsListAction(){
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'categoryTopicsList',
        ], $this->req));
    }

    function addCateTopicsAction(){
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'manageCategoryTopics',
            'type' => 'add'
        ], $this->req));
    }

    function delCateTopicsAction(){
        $this->fetchData(array_merge([
            'do'     => $this->do,
            'format' => 'json',
            'operate' => 'manageCategoryTopics',
            'type' => 'del'
        ], $this->req));
    }

}

new PinkDiary2;